// 视频相关的model
package models

import "time"

//视频
type Videos struct {
	VideoID     int    `json:"videoId" gorm:"primary_key;comment:视频ID"`
	UserID      int    `json:"userID" gorm:"index;not null;comment:用户ID"`
	Title       string `json:"title" gorm:"type:varchar(255);not null;comment:视频标题"`
	Description string `json:"description" gorm:"type:text;comment:视频描述"`
	VideoPath   string `json:"videoPath" gorm:"not null;comment:视频路径"`
	CoverPath   string `json:"coverPath" gorm:"not null;comment:封面路径"`
	Business    string `json:"business" gorm:"type:varchar(255);not null;comment:视频业务类型"`
	// ThumbnailPath string    `gorm:"type:varchar(255);not null;comment:缩略图路径"`
	Duration      int   `json:"duration" gorm:"not null;comment:视频时长"`
	ViewsCount    int64 `json:"viewsCount" gorm:"default:0;comment:观看次数"`
	LikesCount    int64 `json:"likesCount" gorm:" default:0;comment:点赞次数"`
	CommentsCount int64 `json:"commentsCount" gorm:"default:0;comment:评论次数"`
	// Timestamps
	CreatedAt time.Time `json:"createdAt" gorm:"default:CURRENT_TIMESTAMP;comment:创建时间"`
	UpdatedAt time.Time `json:"updatedAt" gorm:"default:CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;comment:更新时间"`
	Status    string    `json:"status" gorm:"type:enum('public', 'private', 'deleted');default:'public';comment:视频状态"`
}

//视频评论
type Comments struct {
	CommentID int       `gorm:"primary_key;comment:评论ID"`
	VideoID   int       `gorm:"index;not null;comment:视频ID"`
	UserID    int       `gorm:"index;not null;comment:用户ID"`
	Content   string    `gorm:"type:text;not null;comment:评论内容"`
	CreatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP;comment:创建时间"`
	SoftDeletes
}

//like点赞
type Likes struct {
	LikeID    int       `gorm:"primary_key;comment:点赞ID"`
	VideoID   int       `json:"videoId" gorm:"index;not null;comment:视频ID"`
	UserID    int       `json:"userId" gorm:"index;not null;comment:用户ID"`
	CreatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP;comment:点赞时间"`
}

//播放历史
type PlayHistory struct {
	HistoryID       int       `gorm:"primary_key;comment:历史记录ID"`
	VideoID         int       `gorm:"index;not null;comment:视频ID"`
	UserID          int       `gorm:"index;not null;comment:用户ID"`
	WatchedAt       time.Time `gorm:"default:CURRENT_TIMESTAMP;comment:观看时间"`
	DurationWatched int       `gorm:"not null;comment:观看时长"`
}
